package com.woyao;

import android.app.Activity;
import android.app.Application;
import android.content.res.Resources;

import org.afinal.simplecache.ACache;

/**
 * Created by summerwind on 2016-05-11.
 */
public class WoyaoooApplication extends Application {
    public static Resources resources;

    public static String apikey  ="";
    public static String apisecret ="";
    public static Integer userId =0 ;
    public static Integer context =0 ;
    public static String username = "";
    public static String displayname="";
    public static String snailview="";
    public static String org="";
    public static boolean hasLogin(){
        return userId != null;
    }
    @Override
    public void onCreate(){
        super.onCreate();
        resources = getResources();

    }

    public static void increase(Activity activity){
        ACache cache = ACache.get(activity);
        Integer count = (Integer)cache.getAsObject("NEXT_COUNT_"+userId);
        if(count == null){
            count = 1;
        }else{
            count = count+1;
        }
        cache.put("NEXT_COUNT_"+userId, count, ACache.TIME_DAY*365);
    }

    public static int getNextCount(Activity activity){
        ACache cache = ACache.get(activity);
        Integer count = (Integer)cache.getAsObject("NEXT_COUNT_"+userId);
        if(count == null){
            return 0;
        }
        return count;
    }
}
